layui.config({
    base: "../js/"
}).use(['jquery', 'frame', 'table', 'form', 'http', 'config'], function () {
    var $table = layui.table,
        $ = layui.jquery,
        $form = layui.form,
        $frame = layui.frame(),
        $cfg = layui.config(),
        $http = layui.http();
    $("#sub-editPwd").click(function () {
        var oldPwd = $("#oldPwd").val(),
            newPwd=$("#newPwd").val(),
            repeatePwd = $("#repeatePwd").val();
        if(!oldPwd || !newPwd || !repeatePwd) {
            $frame.message("请完善资料");
            return;
        }
        if (newPwd != repeatePwd) {
            $frame.message("新密码与确认密码不一致，请重新输入！");
            $("#newPwd").focus();
            return;
        }
        var data = $http.request("acp/changePwd.json", {
            oldPwd: oldPwd,
            newPwd: newPwd
        });
        if (data.status == 0) {
            layer.open({
                content: '修改成功！请您重新登录',
                // btn: ['确认', '取消'],
                btn: ['确认'],
                yes: function (index, layero) {
                    window.parent.location.href=$cfg.config.baseUrl;
                }
            });
        } else {
            $frame.message(data.msg);
        }
    });
});



